class Solution:
    def largestPerimeter(self, A: List[int]) -> int:
        A.sort()
        def judgeTran(index):
            if A[index-2]+A[index-1]<=A[index]:
                return False
            else:
                return True
        #print(A)
        index=len(A)-1
        while index>=2:
            if judgeTran(index):
                #print(index)
                return A[index]+A[index-1]+A[index-2]
            else:
                index-=1
        return 0

'''
88.5%
8%
'''